import sys
from pinpong.extension.unihiker import *
from pinpong.board import Board,Pin,NeoPixel,IRRemote,IRRecv
class SHIELD:
    def __init__(self):
        self.ir = self.IR()
        self.m1 = self.M1()
        self.m2 = self.M2()

    
    
    class IR:
        def __init__(self):
            self.data = ''
        
        def send(self,data):
            self.data = data
            p_p15_irSend=IRRemote(Pin(Pin.P15))
            p_p15_irSend.send(self.data)
        
        def recv(self,event):
            ir1 = IRRecv(Pin((Pin.P14)),event)
        
        def getRecvData(self):
            return self.data
        
    
    class M1:
        def __init__(self):
            pass
            
        
        def run(self,direction,speed):
            M1_veer = Pin(Pin.P5, Pin.OUT)
            M1_speed = Pin(Pin.P8, Pin.PWM)
            M1_veer.write_digital(direction)
            M1_speed.write_analog(speed)
            
        def stop(self):
            M1_speed = Pin(Pin.P8, Pin.PWM)
            M1_speed.write_analog(0)
        
    
    class M2:
        def __init__(self):
            pass
        
        def run(self,direction,speed):
            M2_veer = Pin(Pin.P6, Pin.OUT)
            M2_speed = Pin(Pin.P16, Pin.PWM)
            M2_veer.write_digital(direction)
            M2_speed.write_analog(speed)
            
        def stop(self):
            M2_speed = Pin(Pin.P16, Pin.PWM)
            M2_speed.write_analog(0)   
            
    
if __name__ == "__main__":
    shield = SHIELD()
    shield.m1.run(1,800)
    shield.m2.run(1,800)
    
    